package practise.hibernate.Service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import practise.hibernate.Service.MoiveService;
import practise.hibernate.dao.MoiveDao;
import practise.hibernate.persistence.MoiveRecord;

import java.util.List;

@Service("moiveService")
@Repository
@Transactional
public class MoiveServiceImpl implements MoiveService {
    @Autowired
    private MoiveDao moiveDao;

    @Override
    @Transactional(readOnly = true)
    public List<MoiveRecord> findAllMoivees() {
        return moiveDao.findAllMoivees();
    }

    @Override
    @Transactional(readOnly = false)
    public void deleteMoive(int id) {
        moiveDao.deleteMoive(id);
    }

    @Override
    @Transactional(readOnly = true)
    public List<MoiveRecord> findByLocation(String name) {
        return moiveDao.findByLocation(name);
    }

    @Override
    @Transactional
    public MoiveRecord merge(MoiveRecord moive) {
        return moiveDao.merge(moive);
    }

    @Override
    @Transactional
    public MoiveRecord add(MoiveRecord moive) {
        return moiveDao.merge(moive);
    }
}
